package com.sweets.look.receiver;

import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.sweets.look.R;
import com.sweets.look.ui.activity.BrowserActivity;
import com.sweets.look.util.ViewUtils;

public class BrowserBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String v0 = intent.getAction();
        if ("android.intent.action.DOWNLOAD_COMPLETE".equals(v0)) {
            ViewUtils.showToast(context.getResources().getString(R.string.download_completed), context);
            return;
        }

        if ("android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED".equals(v0)) {
            Intent intent1 = new Intent("android.intent.action.VIEW_DOWNLOADS");
            intent1.setFlags(268435456);
            try {
                context.startActivity(intent1);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }

            return;
        }

        if ("android.net.conn.CONNECTIVITY_CHANGE".equals(v0)) {
            ((BrowserActivity) context).onSettingsChanged();
        }
    }
}

